package com.sumainfor.wx.tenant.controller.rentadviser;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.wx.tenant.feign.Zfeign.ZpcGmioFeign;
import com.sumainfor.wx.tenant.feign.Zfeign.ZpcMktFeign;
import com.sumainfor.wx.tenant.feign.Zfeign.ZzuulFeign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.Map;

/**
 * 租客端调用活动相关
 */
@RestController
@RequestMapping("/rentadviser/RdWxChargesDept")
public class RdWxChargesDeptController implements Serializable {
    Logger log = LoggerFactory.getLogger(RdWxChargesDeptController.class);// 日志
    @Autowired
    private ZpcGmioFeign zpcGmioFeign;
    @Autowired
    private ZzuulFeign zzuulFeign;
    /**
     * 根据房源编号查询活动优惠之后的价格
     */
    @GetMapping("/getChargesDeptWx")
    public JsonResult getChargesDeptWx(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        //先根据房源的签署公司编号查询出签署公司所在的市编号
        JsonResult zuulResult=zzuulFeign.getSysArea(params);
        //如果查询网关的接口返回正常
        if (zuulResult.get("errorCode").toString().equals("0")){
            if (zuulResult.get("result")==null){
                log.debug("查询不到公司所在的市编号");
                result.putFailed("服务器繁忙");
            }else{
                params.put("areaId",params.get("area_id"));
                result=zpcGmioFeign.getChargesDeptWx(params);
            }
        }
        return result;
    }
}
